@{
    ViewBag.Title = "Excel转Json";
    ViewBag.keywords = "JSON,JSON在线,json解析, json在线解析,json教程,json数组,JSON 校验,格式化JSON,xml转json 工具,在线json格式化工具,json 格式化,json格式化工具,json字符串格式化, json在线,json 在线验证,json 在线校验";
    ViewBag.description = "提供json解析,json在线解析,json教程,json数组,JSON在线,JSON在线校验工具,JSON,JSON 校验,格式化,xml转json 工具,json视图,在线json格式化工具,json 格式化,json格式化工具,json字符串格式化,json 在线查看器,json在线,json 在线验证";
var host = Appsettings.app("BaseFile:HostUrl");}
<div class="layui-row layui-form layui-form-pane excel2json">
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">内容：</label>
        <div class="layui-input-block">
            <textarea placeholder="请在excel里复制下内容贴到上面一个文本框里" id="content" name="content" rows="8" lay-verify="required" autocomplete="off" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-inline" style="margin:10px auto;text-align:center; ">
        <label class="layui-form-label">分隔符：</label>
        <div class="layui-input-inline">
            <input type="text" id="fgfstr" placeholder="默认是制表符" class="layui-input">
        </div>
        <div class="layui-input-inline">
            <select style="width:150px;" id="ctype" class="layui-input">
                <option value="0" selected>按行转成对象</option>
                <option value="1">按行转成数组</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item base16">
        <a class="layui-btn cpr">转换</a>
        <a class="layui-btn layui-btn-primary dem">示例</a>
        <a class="layui-btn layui-btn-danger cle">清空</a>
        <a class="layui-btn layui-btn-primary copy">复制结果</a>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">输出：</label>
        <div class="layui-input-block">
            <textarea placeholder="输出内容" id="outtxt" name="outtxt" rows="8" autocomplete="off" class="layui-textarea"></textarea>
        </div>
    </div>
</div>

@section Scripts {
<script type="text/javascript">
    layui.config({ base: '@host/js/' }).use(['common'],function(){ $=layui.jquery;
        var common=layui.common;
        var excel2json=layui.excel2json;
     let area_input = document.getElementById('content');
     let area_output = document.getElementById('outtxt');

     /*3. excel2json start*/
     $(".excel2json .cpr").bind("click", function () {
         let fgefu = document.getElementById('fgfstr');
         var ctype = $("#ctype").val();
         var code = excel2json.ctyperow(area_input, fgefu, ctype);
         area_output.value = code;
     });
     $(".excel2json .dem").bind("click", function () { $("#content").val("时间	价格\n201901	6\n201902	1\n201903	9\n201904	14\n201905	7\n201906	20"); });
     /*excel2json end*/
        });
</script>
}